package com.ayoka.mvp;

import com.ayoka.Constant;
import com.ayoka.R;
import com.ayoka.base.BasePresenter;
import com.ayoka.base.IBaseView;
import com.ayoka.bean.BaseResponse;
import com.ayoka.bean.CoursePackageBean;
import com.ayoka.http.API;
import com.ayoka.http.OkHttpListener;
import com.jcp.baselibrary.utils.UIUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * Created by gabriel on 2017/3/5.
 */

public interface HomeMVP {

    interface  HomeModel {

    }

    interface IHomeView extends IBaseView {

        void configCoursePackageListData(List<CoursePackageBean> purchased_package);
    }

    class HomePresenter extends BasePresenter<IHomeView> {

        public void getCoursePackageListData() {
            mViewRef.get().showWaitDialog(UIUtils.getString(R.string.loading));
            API.getCoursePackageListData(this, new OkHttpListener<BaseResponse<List<CoursePackageBean>>>() {
                @Override
                public void onSuccess(BaseResponse<List<CoursePackageBean>> response) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().configCoursePackageListData(response.data);
                }

                @Override
                public void onFailure(int errorCode, String errorMessage) {
                    if (!isAttached()) return;
                    mViewRef.get().hideWaitDialog();
                    mViewRef.get().showToast(errorMessage);
                }
            });
        }
    }

}
